package com.yhg.qxmall.socket.service.impl;

import com.yhg.qxmall.socket.entity.DailyEntity;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yhg.common.utils.PageUtils;
import com.yhg.common.utils.Query;

import com.yhg.qxmall.socket.dao.InfoDao;
import com.yhg.qxmall.socket.entity.InfoEntity;
import com.yhg.qxmall.socket.service.InfoService;

import javax.sound.sampled.Line;


@Service("infoService")
public class InfoServiceImpl extends ServiceImpl<InfoDao, InfoEntity> implements InfoService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<InfoEntity> page = this.page(
                new Query<InfoEntity>().getPage(params),
                new QueryWrapper<InfoEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public Map<String, Object> getInfoData() {
        QueryWrapper<InfoEntity> wrapper = new QueryWrapper<>();
        wrapper.select("area","dan","lin","jia");
        List<InfoEntity> infoList = baseMapper.selectList(wrapper);

        List<Integer> areaList = new ArrayList<>();
        Map<String, Object> Datamap = new HashMap<>();
        List<Integer> danList = new ArrayList<>();
        List<Integer> linList = new ArrayList<>();
        List<Integer> jiaList = new ArrayList<>();
            //遍历查询所有数据list集合，进行封装
            for (int i = 0; i < infoList.size(); i++) {
                InfoEntity info = infoList.get(i);
                areaList.add(info.getArea());
                danList.add(info.getDan());
                linList.add(info.getLin());
                jiaList.add(info.getJia());
                Datamap.put("dan",danList);
                Datamap.put("lin",linList);
                Datamap.put("jia",jiaList);
            }


        //把封装之后两个list集合放到map集合，进行返回
        Map<String, Object> map = new HashMap<>();
        map.put("area",areaList);
        map.put("Datamap",Datamap);
        return map;
    }

}